package com.changpei.search.utils;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 *
 *
 * @author Way on 2021/9/18
 */
public class WeightUtil {

    /**
     * 根据权重计算结果条数
     * @param countNum
     * @param weightRate
     * @param base
     * @return
     */
    public static Integer countWithWeight(Integer countNum, Integer weightRate) {
        BigDecimal one = new BigDecimal(countNum);
        BigDecimal two = new BigDecimal(weightRate);
        BigDecimal three = new BigDecimal("100");

        return one.multiply(two.divide(three)).setScale(0,
                RoundingMode.DOWN).intValue();
    }

    public static void main(String[] args) {
        System.out.println(countWithWeight(50, 10));
    }
}
